package top.infopub.enums.fia;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum FiaProcessDetailTypeEnum {
    PRO_NODE_TYPE1("1", "预算管理"),
    PRO_NODE_TYPE2("2", "月度资金计划"),
    PRO_NODE_TYPE3("3", "预算审批"),
    PRO_NODE_TYPE4("4", "收款登记"),
    PRO_NODE_TYPE5("5", "资金支付"),
    PRO_NODE_TYPE6("6", "资金上交"),
    PRO_NODE_TYPE7("7", "资金拨付"),
    PRO_NODE_TYPE8("8", "发票管理")
    ;

    private String node;

    private String nodeName;

    FiaProcessDetailTypeEnum(String node, String nodeName) {
        this.node = node;
        this.nodeName = nodeName;
    }

    public static FiaProcessDetailTypeEnum getByNode(String node) {
        if (StringUtils.isBlank(node)) return null;
        for (FiaProcessDetailTypeEnum fpdt : FiaProcessDetailTypeEnum.values()) {
            if (StringUtils.equals(node, fpdt.getNode())) {
                return fpdt;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (FiaProcessDetailTypeEnum fpdt : FiaProcessDetailTypeEnum.values()) {
            map = new HashMap<>();
            map.put("node", fpdt.getNode());
            map.put("nodeName", fpdt.getNodeName());
            list.add(map);
        }
        return list;
    }

    public String getNode() {
        return node;
    }

    public void setNode(String node) {
        this.node = node;
    }

    public String getNodeName() {
        return nodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }
}
